use crate::local_history::entry::TimelineEntry;
use crate::local_history::git_provider;
use crate::local_history::local_provider;

#[tauri::command]
pub async fn get_timeline(path: String) -> Result<Vec<TimelineEntry>, String> {
    let mut git_history = match git_provider::get_git_history(&path) {
        Ok(history) => history,
        Err(_) => vec![],
    };
    let mut local_history = local_provider::get_local_history(&path);

    git_history.append(&mut local_history);
    git_history.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));

    Ok(git_history)
}